package com.chain.BrotherExchange.data;

import com.chain.BrotherExchange.BuildConfig;
import com.chain.BrotherExchange.data.model.AddLegalTenderOrder;
import com.chain.BrotherExchange.data.model.AlipayInfo;
import com.chain.BrotherExchange.data.model.AnnouncementList;
import com.chain.BrotherExchange.data.model.Appeal;
import com.chain.BrotherExchange.data.model.ApplyUnlcokList;
import com.chain.BrotherExchange.data.model.AuthenticationNumber;
import com.chain.BrotherExchange.data.model.BankCardInfo;
import com.chain.BrotherExchange.data.model.BannerList;
import com.chain.BrotherExchange.data.model.BaseResponseModel;
import com.chain.BrotherExchange.data.model.ChargeMoney;
import com.chain.BrotherExchange.data.model.ChargeMoneyDetails;
import com.chain.BrotherExchange.data.model.ChattingRecords;
import com.chain.BrotherExchange.data.model.CheckVersion;
import com.chain.BrotherExchange.data.model.CoinAssetsDetails;
import com.chain.BrotherExchange.data.model.CoinAssetsList;
import com.chain.BrotherExchange.data.model.CoinOrderList;
import com.chain.BrotherExchange.data.model.CoinTypeList;
import com.chain.BrotherExchange.data.model.CountryCodeList;
import com.chain.BrotherExchange.data.model.EntrustQueue;
import com.chain.BrotherExchange.data.model.ExtractCoinAddressList;
import com.chain.BrotherExchange.data.model.ExtractMoneyDetails;
import com.chain.BrotherExchange.data.model.GetttestApi;
import com.chain.BrotherExchange.data.model.LegalTenderAssetsList;
import com.chain.BrotherExchange.data.model.LegalTenderAssetsDetails;
import com.chain.BrotherExchange.data.model.LegalTenderBalance;
import com.chain.BrotherExchange.data.model.LegalTenderDealList;
import com.chain.BrotherExchange.data.model.LegalTenderOrderDetails;
import com.chain.BrotherExchange.data.model.LegalTenderOrderList;
import com.chain.BrotherExchange.data.model.LegalTenderUnitPrice;
import com.chain.BrotherExchange.data.model.LegalTenderUserInfo;
import com.chain.BrotherExchange.data.model.MarketPair;
import com.chain.BrotherExchange.data.model.MoneyRecordModel;
import com.chain.BrotherExchange.data.model.MyInvitationCode;
import com.chain.BrotherExchange.data.model.OtherDetails;
import com.chain.BrotherExchange.data.model.PayPalInfo;
import com.chain.BrotherExchange.data.model.ProcedureFee;
import com.chain.BrotherExchange.data.model.Quotation;
import com.chain.BrotherExchange.data.model.QuotationTypes;
import com.chain.BrotherExchange.data.model.SingleCoinBalance;
import com.chain.BrotherExchange.data.model.TethNumberModel;
import com.chain.BrotherExchange.data.model.TokenTradeModel;
import com.chain.BrotherExchange.data.model.TradingVolume;
import com.chain.BrotherExchange.data.model.TransferDetailsList;
import com.chain.BrotherExchange.data.model.UploadFiles;
import com.chain.BrotherExchange.data.model.UserAreaCode;
import com.chain.BrotherExchange.data.model.UserAssets;
import com.chain.BrotherExchange.data.model.UserInfo;
import com.chain.BrotherExchange.data.model.UserIsAuthentication;
import com.chain.BrotherExchange.data.model.UserLogin;
import com.chain.BrotherExchange.data.model.UserPayment;
import com.chain.BrotherExchange.data.model.VisualQuotation;
import com.chain.BrotherExchange.data.model.WeChatPayInfo;
import com.chain.BrotherExchange.utils.NetWorkUtil;
import com.chain.BrotherExchange.utils.Strings;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

import okhttp3.CacheControl;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;

public interface WebService {

    /**
     * 首页大广告
     */
    @GET("content/bannerlist")
    Call<BannerList> bannerList();

    /**
     * 交易所成交量
     */
    @GET("market/volume")
    Call<TradingVolume> tradingVolume();

    /**
     * 所有货币类型
     */
    @GET("common/token_list")
    Call<CoinTypeList> coinTypeList();

    /**
     * 国家区域
     */
    @GET("common/region")
    Call<CountryCodeList> countryCodeList();

    /**
     * 行情类型
     */
    @GET("market/symbols_title")
    Call<QuotationTypes> quotationTypes();

    /**
     * 市场行情
     */
    @GET("market/quotation")
    Call<Quotation> quotation(@Query("token_id") int typeId);

    /**
     * 检查版本
     */
    @GET("user/version")
    Call<CheckVersion> checkVersion(@Query("sys") int systemType);

    /**
     * 用户信息
     */
    @GET("action/get_user_info")
    Call<UserInfo> userInfo(@Query("uid") int uid, @Query("token") String token);

    /**
     * 登录
     *
     * @param mobilePhone 手机
     * @param password    密码
     * @param type        1-电话登陆 2-邮箱登陆
     */
    @FormUrlEncoded
    @POST("user/login")
    Call<UserLogin> login(
            @Field("ukey") String mobilePhone, @Field("pwd") String password, @Field("type") int type
    );

    /**
     * 忘记密码
     *
     * @param type 1-手机 2-邮箱
     */
    @FormUrlEncoded
    @POST("user/forget")
    Call<BaseResponseModel> forgetPassword(
            @Field("ukey") String mobilePhone, @Field("pwd") String password,
            @Field("code") String code, @Field("type") int type
    );

    /**
     * 根据手机号获取用户区号
     *
     * @param type 1-手机 2-邮箱 3-用户ID
     */
    @GET("user/get_auth_method")
    Call<UserAreaCode> getUserAreaByMobilePhone(@Query("ukey") String mobilePhone, @Query("type") int type);

    /**
     * 发送短信验证码
     *
     * @param type 1-注册,2-忘记密码,3-修改手机号码,4-重置谷歌验证码,5-重置资金密码,6-修改登录密码
     *             7-设置银行卡支付,8-设置微信支付,9-设置支付宝支付,10-设置PayPal支付,11-绑定手机
     *             12-绑定邮箱,13-提币,14-实名认证
     */
    @FormUrlEncoded
    @POST("user/send_sms")
    Call<BaseResponseModel> sendSms(
            @Field("region") String region, @Field("phone") String mobilePhone, @Field("type") int type
    );

    /**
     * 修改用户信息
     *
     * @param portrait 用户头像
     */
    @FormUrlEncoded
    @POST("user/set_nickname")
    Call<BaseResponseModel> modifyUserInfo(
            @Field("uid") int uid, @Field("token") String token,
            @Field("nick_name") String nickname, @Field("file") String portrait
    );

    /**
     * 修改交易密码
     */
    @FormUrlEncoded
    @POST("/user/modify_trade_pwd")
    Call<BaseResponseModel> modifyTransactionPassword(
            @Field("uid") int uid, @Field("token") String token, @Field("new_pwd") String newPwd,
            @Field("confirm_pwd") String confirmPwd, @Field("verify") String verifyCode
    );

    /**
     * 修改登录密码
     */
    @FormUrlEncoded
    @POST("user/modify_login_pwd")
    Call<BaseResponseModel> modifyLoginPassword(
            @Field("uid") int uid, @Field("token") String token, @Field("new_pwd") String newPwd,
            @Field("old_pwd") String oldPwd, @Field("confirm_pwd") String confirmPwd,
            @Field("verify") String verifyCode
    );

    /**
     * 我的邀请码
     */
    @GET("action/get_user_invite")
    Call<MyInvitationCode> myInvitationCode(@Query("uid") int uid, @Query("token") String token);

    /**
     * 身份认证次数
     */
    @GET("user/verify_count")
    Call<AuthenticationNumber> authenticationNumber(@Query("uid") int uid);

    /**
     * 实名认证
     */
    @FormUrlEncoded
    @POST("user/first_verify")
    Call<BaseResponseModel> realNamAuthentication(
            @Field("uid") int uid, @Field("token") String token, @Field("id") String id,
            @Field("name") String name, @Field("code") String code
    );

    /**
     * 是否认证
     */
    @GET("action/get_user_real")
    Call<UserIsAuthentication> userIsAuthentication(
            @Query("uid") int uid, @Query("token") String token
    );

    /**
     * 公告
     */
    @GET("article/list")
    Call<AnnouncementList> announcementList(
            @Query("type") int type, @Query("page") int page, @Query("rows") int rows
    );

    /**
     * 用户资产
     */
    @GET("token/all_list")
    Call<UserAssets> userAssets(
            @Query("uid") int uid, @Query("token") String token
//            , @Query("token_id") int id, @Query("no_zero") boolean state
    );

    /**
     * 添加提币地址
     *
     * @param id 币种id
     */
    @FormUrlEncoded
    @POST("wallet/address/save")
    Call<BaseResponseModel> addCoinAddress(
            @Field("token") String token, @Field("uid") int uid, @Field("token_id") int id,
            @Field("address") String address, @Field("mark") String remark
    );

    /**
     * 提币地址列表
     */
    @GET("wallet/address/list")
    Call<ExtractCoinAddressList> extractAddressList(
            @Query("uid") int uid, @Query("token") String token
    );

    /**
     * 删除提币地址
     */
    @FormUrlEncoded
    @POST("wallet/address/delete")
    Call<BaseResponseModel> deleteExtractAddress(
            @Field("token") String token, @Field("uid") int uid, @Field("id") String id
    );

    /**
     * 法币明细
     */
    @GET("currency/get_asset_detail")
    Call<LegalTenderAssetsDetails> legalTenderAssetsDetails(
            @Query("token") String token, @Query("uid") int uid, @Query("page") int page,
            @Query("page_num") int number
    );

    /**
     * 币币明细
     */
    @GET("token/trade_list")
    Call<CoinAssetsDetails> coinAssetsDetailsList(
            @Query("uid") int uid, @Query("token") String token, @Query("page") int page,
            @Query("page_num") int rows
    );

    /**
     * 充币明细
     */
    @GET("wallet/in_list")
    Call<ChargeMoneyDetails> chargeMoneyDetailsList(
            @Query("uid") int uid, @Query("token") String token, @Query("page") int page,
            @Query("page_num") int rows
    );

    /**
     * 提币明细
     */
    @GET("wallet/out_list")
    Call<ExtractMoneyDetails> extractMoneyDetailsList(
            @Query("uid") int uid, @Query("token") String token, @Query("page") int page,
            @Query("page_num") int rows
    );

    /**
     * 划转明细
     */
    @GET("token/transfer_list")
    Call<TransferDetailsList> transferDetailsList(
            @Query("uid") int uid, @Query("token") String token, @Query("page") int page,
            @Query("page_num") int rows
    );

    /**
     * 其他明细
     */
    @GET("token/refund_list")
    Call<OtherDetails> otherDetailsList(
            @Query("uid") int uid, @Query("token") String token, @Query("page") int page,
            @Query("page_num") int rows
    );

    /**
     * 取消提币
     */
    @FormUrlEncoded
    @POST("wallet/tibi_cancel")
    Call<BaseResponseModel> cancelExtractMoney(
            @Field("uid") int uid, @Field("token") String token, @Field("id") int id
    );

    /**
     * 买卖盘
     */
    @GET("market/entrust_quenes")
    Call<EntrustQueue> entrustQueue(@Query("symbol") String symbol);

    /**
     * 币币订单
     */
    @GET("token/entrust_history")
    Call<CoinOrderList> coinOrderList(
            @Query("uid") int uid, @Query("token") String token, @Query("page") int page,
            @Query("limit") int rows
    );

    /**
     * 未完成币币订单
     */
    @GET("token/entrust_list")
    Call<CoinOrderList> unfinishedCoinOrder(
            @Query("uid") int uid, @Query("token") String token, @Query("page") int page,
            @Query("limit") int rows
    );

    /**
     * 撤销币币订单
     */
    @FormUrlEncoded
    @POST("token/del_entrust")
    Call<BaseResponseModel> cancelCoinOrder(
            @Field("token") String token, @Field("uid") int uid, @Field("entrust_id") String id,
            @Field("sign") String sign, @Field("nonce_str") String nonce
    );

    /**
     * 币币资产列表
     */
    @GET("token/balance_list")
    Call<CoinAssetsList> coinAssetsList(
            @Query("uid") int uid, @Query("token") String token
    );

    /**
     * 法币资产列表
     */
    @GET("currency/get_user_currency")
    Call<LegalTenderAssetsList> legalTenderAssetsList(
            @Query("uid") int uid, @Query("token") String token
    );

    /**
     * 充币
     */
    @FormUrlEncoded
    @POST("wallet/create")
    Call<ChargeMoney> chargeMoney(
            @Field("token") String token, @Field("uid") int uid, @Field("token_id") String id
    );

    /**
     * 提币手续续
     */
    @GET("user/fee")
    Call<ProcedureFee> procedureFee();

    /**
     * 提币
     */
    @FormUrlEncoded
    @POST("wallet/tibi_apply")
    Call<BaseResponseModel> extractMoney(
            @Field("token") String token, @Field("uid") int uid, @Field("token_id") String id,
            @Field("to") String address, @Field("amount") String amount, @Field("gasprice") String gas,
            @Field("real_amount") String realAmount, @Field("sms_code") String code,
            @Field("password") String password, @Field("phone") String phone
    );

    /**
     * 币币划转到法币
     */
    @FormUrlEncoded
    @POST("token/transfer_to_currency")
    Call<BaseResponseModel> transferToCurrency(
            @Field("token") String token, @Field("uid") int uid, @Field("token_id") String id,
            @Field("num") Double number
    );

    /**
     * 法币划转到币币
     */
    @FormUrlEncoded
    @POST("currency/transfer_to_token")
    Call<BaseResponseModel> transferToLegalTender(
            @Field("token") String token, @Field("uid") int uid, @Field("token_id") String id,
            @Field("num") Double number
    );

    /**
     * 单币种余额
     */
    @GET("token/balance")
    Call<SingleCoinBalance> singleCoinBalance(
            @Query("uid") int uid, @Query("token") String token, @Query("token_id") String id
    );


    /**
     * 注册
     */
    @FormUrlEncoded
    @POST("user/register")
    Call<BaseResponseModel> register(
            @Field("ukey") String phone, @Field("pwd") String password, @Field("country") int country,
            @Field("invite_code") String inviteCode, @Field("confirm") String confirmPassword,
            @Field("type") int type, @Field("code") String code
    );

    /**
     * 上传图片
     */
    @FormUrlEncoded
    @POST("user/upload_picture")
    Call<UploadFiles> uploadFile(@Field("file") String base64);

    /**
     * 委托订单
     *
     * @param symbol 交易对符号
     * @param option 1-买    2-卖
     * @param type   1-市价委托  2-限价委托
     */
    @FormUrlEncoded
    @POST("token/entrust_order")
    Call<BaseResponseModel> entrustOrder(
            @Field("uid") int uid, @Field("token") String token, @Field("symbol") String symbol,
            @Field("opt") int option, @Field("on_price") double onPrice, @Field("type") int type,
            @Field("num") double number, @Field("sign") String sign, @Field("nonce_str") String nonce
    );

    /**
     * 极验 api 1
     */
    @GET("user/api1")
    Call<GetttestApi> gettestApiFirst(@Query("phone") String phone);

    /**
     * 极验 api 2
     */
    @FormUrlEncoded
    @POST("user/api2")
    Call<BaseResponseModel> gettestApiSecond(
            @Field("phone") String phone, @Field("challenge") String challenge,
            @Field("validate") String validate, @Field("seccode") String seccode,
            @Field("status") int status
    );

    /**
     * 法币交易列表
     */
    @GET("currency/otc_list")
    Call<LegalTenderDealList> legalTenderDealList(
            @Query("type_id") int type, @Query("token_id") int tokenId, @Query("page") int page,
            @Query("page_num") int rows
    );

    /**
     * 法币订单列表
     */
    @GET("currency/orders")
    Call<LegalTenderOrderList> legalTenderOrderList(
            @Query("uid") int uid, @Query("token") String token, @Query("page") int page,
            @Query("page_num") int number
    );

    /**
     * 取消法币订单
     *
     * @param cancelType 取消类型: 1-卖方 2-买方 3-系统
     */
    @FormUrlEncoded
    @POST("currency/cancel_order")
    Call<BaseResponseModel> cancelLegalTenderOrder(
            @Field("uid") int uid, @Field("token") String token, @Field("id") int orderId,
            @Field("cancel_type") int cancelType
    );

    /**
     * 法币订单-确认支付
     */
    @FormUrlEncoded
    @POST("currency/ready_order")
    Call<BaseResponseModel> confirmPayment(
            @Field("uid") int uid, @Field("token") String token, @Field("id") int orderId
    );

    /**
     * 已设置支付方式
     */
    @GET("currency/get_pay_set")
    Call<UserPayment> userPayment(@Query("uid") int uid, @Query("token") String token);

    /**
     * 添加/修改银行卡支付
     */
    @FormUrlEncoded
    @POST("currency/bank_pay")
    Call<BaseResponseModel> addBankPayment(
            @Field("uid") int uid, @Field("token") String token, @Field("name") String name,
            @Field("bank_name") String bankName, @Field("bank_info") String bankAddress,
            @Field("card_num") String bankNumber, @Field("verify_num") String confirmNumber,
            @Field("verify") String code
    );

    /**
     * 添加/修改支付宝
     */
    @FormUrlEncoded
    @POST("currency/alipay")
    Call<BaseResponseModel> addAliPayment(
            @Field("uid") int uid, @Field("token") String token, @Field("name") String name,
            @Field("alipay") String aliPay, @Field("receipt_code") String rqCode, @Field("verify") String code
    );

    /**
     * 添加/修改微信支付
     */
    @FormUrlEncoded
    @POST("currency/wechatpay")
    Call<BaseResponseModel> addWeChatPayment(
            @Field("uid") int uid, @Field("token") String token, @Field("name") String name,
            @Field("wechat") String weChat, @Field("receipt_code") String rqCode, @Field("verify") String code
    );

    /**
     * 添加/修改payPal
     */
    @FormUrlEncoded
    @POST("currency/paypal")
    Call<BaseResponseModel> addPayPalPayment(
            @Field("uid") int uid, @Field("token") String token, @Field("paypal") String payPal,
            @Field("verify") String code
    );

    /**
     * 银行卡信息
     */
    @GET("currency/bank_pay")
    Call<BankCardInfo> bankCardInfo(@Query("uid") int uid, @Query("token") String token);

    /**
     * 支付宝信息
     */
    @GET("currency/alipay")
    Call<AlipayInfo> aliPayInfo(@Query("uid") int uid, @Query("token") String token);

    /**
     * 微信支付信息
     */
    @GET("currency/wechatpay")
    Call<WeChatPayInfo> weChatPayInfo(@Query("uid") int uid, @Query("token") String token);

    /**
     * payPal支付信息
     */
    @GET("currency/paypal")
    Call<PayPalInfo> payPalInfo(@Query("uid") int uid, @Query("token") String token);

    /**
     * 二级认证
     */
    @FormUrlEncoded
    @POST("user/second_verify")
    Call<BaseResponseModel> level2Certification(
            @Field("uid") int uid, @Field("token") String token, @Field("front_path") String front,
            @Field("reverse_path") String reverse, @Field("head_path") String head
    );

    /**
     * 法币个人信息
     */
    @FormUrlEncoded
    @POST("currency/user_currency_rating")
    Call<LegalTenderUserInfo> legalTenderUserInfo(@Field("uid") int uid);

    /**
     * 法币个人交易列表
     */
    @GET("currency/otc_user_list")
    Call<LegalTenderDealList> legalTenderUserDealList(
            @Query("uid") int uid, @Query("type_id") int type, @Query("page") int page,
            @Query("page_num") int number
    );

    /**
     * 法币订单详情
     */
    @GET("currency/trade_detail")
    Call<LegalTenderOrderDetails> legalTenderOrderDetails(
            @Query("uid") int uid, @Query("token") String token, @Query("id") String id
    );

    /**
     * 法币下单
     *
     * @param number 交易数量
     */
    @FormUrlEncoded
    @POST("currency/add_order")
    Call<AddLegalTenderOrder> legalTenderAddOrder(
            @Field("uid") int uid, @Field("token") String token, @Field("ad_id") int id,
            @Field("num") double number
    );

    /**
     * 法币余额
     */
    @GET("currency/currency_balance")
    Call<LegalTenderBalance> legalTenderBalance(
            @Query("uid") int uid, @Query("token") String token, @Query("token_id") int tokenId
    );

    /**
     * 申诉
     */
    @FormUrlEncoded
    @POST("currency/appeal")
    Call<Appeal> legalTenderAppeal(
            @Field("uid") int uid, @Field("token") String token, @Field("token_id") String tokenId,
            @Field("opt") int opt, @Field("order_id") String orderId, @Field("image") String image,
            @Field("mark") String tokenName, @Field("remarks") String remark
    );

    /**
     * 发布法币交易
     */
    @FormUrlEncoded
    @POST("currency/created_otc")
    Call<BaseResponseModel> publishTransaction(
            @Field("uid") int uid, @Field("token") String token, @Field("type_id") int type,
            @Field("token_id") int tokenId, @Field("token_name") String tokenName, @Field("price") double price,
            @Field("num") double number, @Field("premium") int premium, @Field("accept_price") double acceptPrice,
            @Field("min_limit") int minPrice, @Field("max_limit") int maxPrice,
            @Field("is_twolevel") int isVerify, @Field("pays") String pays, @Field("remarks") String remark
    );

    /**
     * 待放行
     */
    @FormUrlEncoded
    @POST("currency/confirm_order")
    Call<BaseResponseModel> orderRelease(
            @Field("uid") int uid, @Field("token") String token, @Field("id") int orderId,
            @Field("pay_pwd") String password, @Field("sign") String sign, @Field("nonce_str") String nonce
    );

    /**
     * 取消申诉
     */
    @FormUrlEncoded
    @POST("currency/cancel_appeal")
    Call<BaseResponseModel> cancelAppeal(
            @Field("uid") int uid, @Field("appeal_id") int appealId, @Field("token") String token
    );

    /**
     * 单价
     */
    @GET("currency/recent_transaction_price")
    Call<LegalTenderUnitPrice> legalTenderUnitPrice(
            @Query("price_type") int type, @Query("token_id") int tokenId
    );

    /**
     * 修改广告状态(我发布的交易单)
     *
     * @param statusId 状态: 1-下架 2-上架 3-正常(不删除) 4-删除
     */
    @FormUrlEncoded
    @POST("currency/updated_otc_status")
    Call<BaseResponseModel> editMyPublishTransactionOrderStatus(
            @Field("uid") int uid, @Field("token") String token, @Field("id") int id,
            @Field("status_id") int statusId
    );

    /**
     * 修改已发布的交易单
     *
     * @param id 订单ID
     */
    @FormUrlEncoded
    @POST("currency/updated_otc")
    Call<BaseResponseModel> editMyPublishTransactionOrder(
            @Field("uid") int uid, @Field("token") String token, @Field("id") int id,
            @Field("price") double price, @Field("num") double number, @Field("premium") int premium,
            @Field("accept_price") double acceptPrice, @Field("min_limit") int minPrice, @Field("max_limit") int maxPrice,
            @Field("is_twolevel") int isVerify, @Field("pays") String pays, @Field("remarks") String remark
    );

    /**
     * K线数据
     */
    @GET("kline/history2")
    Call<VisualQuotation> visualQuotation(
            @Query("symbol") String symbol, @Query("resolution") String resolution,
            @Query("from") long fromDate, @Query("to") long toDate
    );

    /**
     * 最新交易对
     */
    @GET("market/price")
    Call<MarketPair> marketPairData(@Query("symbol") String symbol);

    /**
     * 聊天记录
     */
    @GET("currency/chats_list")
    Call<ChattingRecords> chattingRecords(
            @Query("uid") int uid, @Query("token") String token, @Query("order_id") String orderId
    );

    /**
     * STE交易资格
     */
    @GET("token/get_token_trade")
    Call<TokenTradeModel> getTokenTrade(
            @Query("uid") int uid, @Query("token") String token, @Query("token_id") int orderId
    );

    /**
     * 查询数量
     */
    @FormUrlEncoded
    @POST("token/get_usdt_teth_num")
    Call<TethNumberModel> getTokenTethNumber(@Field("uid") int uid, @Field("token") String token);

    /**
     * 查询币币变更列表
     */
    @FormUrlEncoded
    @POST("token/get_money_record")
    Call<MoneyRecordModel> getMoneyRecord(
            @Field("uid") int uid, @Field("token") String token, @Field("page") int page,
            @Field("page_num") int number, @Field("type") int type
    );

    /**
     * 锁仓
     */
    @FormUrlEncoded
    @POST("token/lock_token")
    Call<BaseResponseModel> lockToken(
            @Field("uid") int uid, @Field("token") String token, @Field("token_id") int tokenId
    );

    /**
     * 申请节点
     */
    @FormUrlEncoded
    @POST("user/apply_node_user")
    Call<BaseResponseModel> applyNode(@Field("uid") int uid, @Field("token") String token);

    /**
     * 申请解锁
     */
    @FormUrlEncoded
    @POST("token/unlock_token_apply")
    Call<BaseResponseModel> unlockApplyToken(
            @Field("uid") int uid, @Field("token") String token, @Field("token_id") int tokenId
    );

    /**
     * 取消申请
     */
    @FormUrlEncoded
    @POST("token/cancel_unlock_token_apply")
    Call<BaseResponseModel> cancelApplyToken(
            @Field("uid") int uid, @Field("token") String token, @Field("id") int id
    );

    /**
     * 查询申请解锁列表
     */
    @GET("token/get_apply_unlock_token_list")
    Call<ApplyUnlcokList> getApplyUnlockList(
            @Query("uid") int uid, @Query("token") String token, @Query("page") int page,
            @Query("rows") int number
    );


    class Helper {
        private static WebService mKLineWebService;

        private static WebService mWebService;

        public static WebService kLine() {
            if (mKLineWebService == null) {
                synchronized (Helper.class) {
                    if (mKLineWebService == null) {
                        new Helper(BuildConfig.K_LINE_BASE_URL);
                    }
                }
            }

            return mKLineWebService;
        }

        public static WebService get() {
            if (mWebService == null) {
                synchronized (Helper.class) {
                    if (mWebService == null) {
                        new Helper();
                    }
                }
            }

            return mWebService;
        }

        Helper() {
            Retrofit mRetrofit = new Retrofit.Builder()
                    .client(okhttpclient())
                    .baseUrl(BuildConfig.BASE_URL)
                    .addConverterFactory(GsonConverterFactory.create())
                    .build();

            mWebService = mRetrofit.create(WebService.class);
        }

        Helper(String baseUrl) {
            Retrofit mRetrofit = new Retrofit.Builder()
                    .client(okhttpclient())
                    .baseUrl(baseUrl)
                    .addConverterFactory(GsonConverterFactory.create())
                    .build();

            mKLineWebService = mRetrofit.create(WebService.class);
        }

        private OkHttpClient okhttpclient() {
            HttpLoggingInterceptor logInterceptor = new HttpLoggingInterceptor();
            logInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);

            return new OkHttpClient.Builder()
                    .connectTimeout(15, TimeUnit.SECONDS)
                    .addInterceptor(new AddHeaderInterceptor())
//                    .cache(new Cache(new File(App.getInstance().getCacheDir(), "HttpCache"),
//                            1024 * 1024 * 100))
                    .addNetworkInterceptor(logInterceptor)

//                    .addNetworkInterceptor(new CacheInterceptor())
                    .build();
        }

        /**
         * 缓存拦截器
         */
        private static class CacheInterceptor implements Interceptor {

            @Override
            public Response intercept(Interceptor.Chain chain) throws IOException {

                int maxAge = 60 * 60;
                int maxStale = 60 * 60 * 24;
                Request request = chain.request();

                if (NetWorkUtil.isNetworkConnected()) {
                    request = request.newBuilder()
                            .cacheControl(CacheControl.FORCE_NETWORK)
                            .build();
                } else {
                    request = request.newBuilder()
                            .cacheControl(CacheControl.FORCE_CACHE)
                            .build();
                }

                Response response = chain.proceed(request);
                if (NetWorkUtil.isNetworkConnected()) {
                    response = response.newBuilder()
                            .removeHeader("Pragma")
                            .header("Cache-Control", "public, max-age=" + maxAge)
                            .build();
                } else {
                    response = response.newBuilder()
                            .removeHeader("Pragma")
                            .header("Cache-Control", "public, only-if-cached, max-stale=" + maxStale)
                            .build();
                }

                return response;
            }
        }

        static RequestBody toRequestBody(String value) {
            if (Strings.isEmpty(value)) {
                return null;
            }

            return RequestBody.create(MediaType.parse("text/plain"), value);
        }

        static RequestBody toRequestBody(int value) {
            return toRequestBody(String.valueOf(value));
        }

        static RequestBody toRequestBody(double value) {
            return toRequestBody(String.valueOf(value));
        }

        static RequestBody toRequestBody(boolean value) {
            return toRequestBody(String.valueOf(value));
        }
    }
}
